package ace.module.upms.core.impl.controller.graphql.admin;

import ace.cmp.security.oauth2.resource.server.core.annotation.PreAuthorizeIsUserAuthenticated;
import ace.cmp.spring.graphql.core.annotation.SchemaExtendMapping;
import ace.cmp.spring.graphql.data.jdbc.querydsl.core.controller.AbstractAdminGraphql;
import ace.module.upms.core.impl.controller.graphql.constant.GraphqlSchemaConstants;
import ace.module.upms.core.impl.service.UpmsMenuService;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import lombok.AllArgsConstructor;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.web.bind.annotation.RestController;
import ace.module.upms.core.impl.dao.entity.UpmsMenu;

/**
* for graphql admin controller.
*
* @author Caspar
*/
@Slf4j
@AllArgsConstructor
@SchemaExtendMapping("upmsMenuAdmin")
@RestController
public class UpmsMenuAdminGraphql extends AbstractAdminGraphql<UpmsMenu, Long> {
  private final UpmsMenuService upmsMenuService;

  /**
   * 获取当前用户的菜单
   *
   * @return
   */
  @PreAuthorizeIsUserAuthenticated
  @QueryMapping(GraphqlSchemaConstants.Query.upmsMenuAdminGetByCurrentUser)
  public List<UpmsMenu> getByCurrentUser() {
    return this.upmsMenuService.getByCurrentAccount();
  }
}